import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "layout",
      component: () => import('@/view/layout/index.vue'),
      redirect: "login",
      children: [
        //登录
        {
          path: "/login",
          name: "login",
          component: () => import('@/view/login/index.vue'),
          meta: {
            title: '登录'
          }
        },
        //主页
        {
          path: "/home",
          name: "home",
          component: () => import('@/view/home/index.vue'),
          redirect: "/home/message",
          children: [{
            path: "message",
            name: "message",
            component: () => import('@/view/home/page/message/index.vue')
          }, {
            path: "contact",
            name: "contact",
            component: () => import('@/view/home/page/contact/index.vue')
          }]
        },
        //添加联系人页面
        {
          path: "/add_contact",
          name: "addContact",
          component: () => import('@/view/add_contact/index.vue'),
        },
        //聊天页面
        {
          path: "/chat_pannel/:id",
          name: "chatpannel",
          component: () => import('@/view/chat_panel/index.vue'),
          meta: {
            title: (route: any) => {
              return `与${route.params.id}的聊天`
            }
          }
        },
        //好友/群申请页面
        {
          path: "contact_apply/:type",
          name: "contactApply",
          component: () => import('@/view/contact_request/index.vue'),
        }
      ]
    }
  ],
})

export default router
